import 'package:flutter_tiktok/controller/tikTokVideoListController.dart';
import 'package:jet_rails/jr_app/jr_models/jr_comment_model.dart';
import 'package:jet_rails/jr_app/jr_models/jr_media_model.dart';
import 'package:jet_rails/jr_app/jr_models/jr_user_model.dart';
import 'package:json_annotation/json_annotation.dart';

part 'jr_video_model.g.dart';

@JsonSerializable()
class JrVideoModel extends JrMediaModel implements VPVideoModel {
  String? authorCode;
  String? videoId;
  @JsonKey(name: 'comments', defaultValue: [])
  List<JrCommentModel>? comments;
  String? title;
  bool like;
  JrVideoModel(
      {String? mediaId,
      String? mediaPath,
      String? mediaType,
      String? mediaUrl,
      String? middleThumbUrl,
      String? sort,
      String? thumbUrl,
      String? userId,
      JrUserModel? author,
      this.comments,
      this.authorCode,
      this.videoId,
      this.title,
      this.like = false})
      : super(
            mediaId: mediaId,
            mediaPath: mediaPath,
            mediaType: mediaType,
            mediaUrl: mediaUrl,
            middleThumbUrl: middleThumbUrl,
            sort: sort,
            thumbUrl: thumbUrl,
            userId: userId,
            author: author);

  // factory JrVideoModel.fromJson(Map<String, dynamic> json) => JrMediaModel.fromJson(json);
  factory JrVideoModel.fromJson(Map<String, dynamic> json) => _$JrVideoModelFromJson(json);

  @override
  Map<String, dynamic> toJson() => _$JrVideoModelToJson(this);

  @override
  String get image => thumbUrl ?? '';

  @override
  String get url => mediaUrl ?? '';

  @override
  String? get desc => '';
}
